<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>

<div id="app">
  <h3 style="text-align: center;">表达式计算器</h3>
  <div class="container">
    <div class="display">
      {{calc.display}}
    </div>
    <div class="tip" v-if="calc.error">
      {{calc.error}}
    </div>
    <div class="zone">
      <button @click="row.press()" class="btn" v-for="(row, i) in calc.btns" :key="i">{{row.value}}</button>
    </div>
  </div>  
</div>
 
  <script src="https://unpkg.com/vue@3/dist/vue.global.js"></script>
  <script src="./index.js"></script>
  <script>

    Vue.createApp({
      data () {
        return {
          calc: new Calculator()
        }
      }
    }).mount('#app')
  </script> 
  
  <style>
    .container {
      width: 480px;
      margin: 40px auto;
      border: 1px solid #e2e2e2;
      border-radius: 4;
    }

    .display {
      height: 64px;
      border-bottom: 1px solid #e2e2e2;
      padding: 8px 12px;
      font-size: 32px;
      display: flex;
      align-items: center;
      justify-content: end;
    }

    .tip {
      color: red;
      font-size: 12px;
      text-align: right;
      padding: 4px 12px;
    }

    .zone {
      padding: 12px 24px;
      display: flex;
      flex-wrap: wrap;
    }

    .btn {
      width: 64px;
      height: 64px;
      border-radius: 4px;
      border: 1px solid #e2e2e2;
      flex: 0 1 auto;
      margin: 10px 20px;
      display: flex;
      justify-content: center;
      align-items: center;
      font-size: 20px;
    }

    .btn:hover {
      opacity: .7;
    }
  </style>
</body>
</html>